<%@ page contentType="text/html;charset=UTF-8" import="java.io.*,java.util.*,java.net.*" language="java" %>
<html>
<head>
    <title></title>
</head>
<>
<%--
request	HttpServletRequest类的实例
response	HttpServletResponse类的实例
out	PrintWriter类的实例，用于把结果输出至网页上
session	HttpSession类的实例
application	ServletContext类的实例，与应用上下文有关
config	ServletConfig类的实例
pageContext	PageContext类的实例，提供对JSP页面所有对象以及命名空间的访问
page	类似于Java类中的this关键字
Exception	Exception类的对象，代表发生错误的JSP页面中对应的异常对象
--%>
getServletName():<%=config.getServletName()%><br/>
getRequestURI():<%=request.getRequestURI()%><br/>
getRemoteAddr():<%=request.getRemoteAddr()%><br/>
getRemoteHost():<%=request.getRemoteHost()%><br/>
getContextPath():<%=request.getContextPath()%><br/>
getServletPath():<%=request.getServletPath()%><br/>
getServerPort():<%=request.getServerPort()%><br/>

==========请求的头部信息<br/>
<%
    Enumeration headerNames = request.getHeaderNames();
    while (headerNames.hasMoreElements()) {
        String paramName = (String) headerNames.nextElement();
        out.print("<tr><td>" + paramName + "</td>" + ":");
        String paramValue = request.getHeader(paramName);
        out.println("<td> " + paramValue + "</td></tr><br/>");
    }
%>
==========请求的响应<br/>
<%
    // 设置每隔5秒自动刷新
    response.setIntHeader("Refresh", 5);
    // 获取当前时间
    Calendar calendar = new GregorianCalendar();
    String am_pm;
    int hour = calendar.get(Calendar.HOUR);
    int minute = calendar.get(Calendar.MINUTE);
    int second = calendar.get(Calendar.SECOND);
    if (calendar.get(Calendar.AM_PM) == 0)
        am_pm = "AM";
    else
        am_pm = "PM";
    String CT = hour + ":" + minute + ":" + second + " " + am_pm;
    out.println("Current Time is: " + CT + "\n");
    //    response.sendError(HttpURLConnection.HTTP_NOT_FOUND, "模拟发生错误");
%>

</body>
</html>
